package openbang.account.service.intf;

import java.util.List;

import openbang.account.service.entity.MsgAsyn;
import openbang.account.service.entity.MsgReceive;
import openbang.account.service.exception.SecurityOBException;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

/**
 * 消息服务
 * 必须登录
 * 隐含都是对当前用户的消息进行操作，所以接口方法都没有用户ID,用户ID来源于Session
 * @author aibo zeng
 *
 */

@RemoteServiceRelativePath("msgService")
public interface MsgService extends RemoteService{

	/**
	 * 查询消息
	 * @param msgStatus 非存档、已存档
	 * @param pageNo    页码   从1开始
	 * @param pageCount 每页记录数  >0
	 * @return
	 * @throws SecurityOBException
	 */
	public List<MsgReceive> getListMsg(int msgStatus , int pageNo,int pageCount) throws SecurityOBException;	

	/**
	 * 获取收件箱的消息
	 * 发送时间 降序
	 * @param pageNo 页码   从1开始
	 * @param pageCount 每页记录数  >0
	 * @return
	 */
	public List<MsgReceive> getReceiveListMsg(int pageNo,int pageCount) throws SecurityOBException;

	/**
	 * 获取存档箱的消息
	 * 发送时间 降序
	 * @param pageNo 页码   从1开始
	 * @param pageCount 每页记录数 >0
	 * @return
	 */
	public List<MsgReceive> getArchiveListMsg(int pageNo,int pageCount) throws SecurityOBException;
	
	/**
	 * 获取收件箱总消息数
	 * @return code @see MsgServiceEnum
	 */
	public Integer countReceiveMsg()  throws SecurityOBException;

	/**
	 * 获取存档箱总消息数
	 * @return code @see MsgServiceEnum
	 */
	public Integer countArchiveMsg()  throws SecurityOBException;
	
	/**
	 * 删除消息
	 * @param msgId 接收人消息的ID
	 * @return code @see MsgServiceEnum
	 */
	public Integer deleteMsg(Long[] msgId)  throws SecurityOBException;

	/**
	 * 存档消息
	 * @param msgId  接收人消息的ID
	 * @return code @see MsgServiceEnum
	 */
	public Integer archiveMsg(Long[] msgId)  throws SecurityOBException;
	
	/**
	 * 发送新的消息
	 * @param msg
	 * @param receivers
	 * @return code 
	 * @see MsgServiceEnum
	 */
	public Integer sendMsg(MsgAsyn msg , String[] receivers)  throws SecurityOBException;

	/**
	 * 置为已读消息
	 * @param msgId  接收人消息的ID
	 * @return code @see MsgServiceEnum
	 */
	public Integer doSetReadMsg(Long msgId)  throws SecurityOBException;
	
    /* @RemoteServiceRelativePath相当于以下用法
     */
    public static class Util {
		private static MsgServiceAsync instance;
		public static MsgServiceAsync getInstance(){
			if (instance == null) {
				instance = (MsgServiceAsync) GWT.create(MsgService.class);
				ServiceDefTarget target = (ServiceDefTarget) instance;
				target.setServiceEntryPoint("/msgService");//GWT.getModuleBaseURL() 
			}
			return instance;
		}
	} 
	   //msgService 必须在 web.xml中声明	
}
